package com.example.administrator.dc.Activity;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.example.administrator.dc.R;
import com.example.administrator.dc.dialog.coustomDialog;

public class Detail extends BaseActivity {
    private   WebView webView;
    private Context context;
    private coustomDialog  coustomDialog;
    private View view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail);
        coustomDialog coustomDialog=new coustomDialog(Detail.this,200,100,R.layout.coustomdialog,R.drawable.camera);
        coustomDialog.getDensity(Detail.this);
       webView= (WebView) findViewById(R.id.webview_detail);
        WebSettings settings=webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setUseWideViewPort(true);
        settings.setLoadWithOverviewMode(true);
        settings.setBuiltInZoomControls(true);
        settings.setSupportZoom(true);
        Intent intent =getIntent();
        String a=String.valueOf(intent.getStringExtra("address"));
        webView.loadUrl(a);
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                // TODO Auto-generated method stub
                //返回值是true的时候控制去WebView打开，为false调用系统浏览器或第三方浏览器
                view.loadUrl(url);
                return true;
            }
        });


    }
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
            webView.goBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
